package com.huizluo.module3.fightmaster;

public class Card implements Comparable<Card>{

    private Style type;
    private String name;

    private Integer weight;

    public Integer getWeight() {
        return weight;
    }

    @Override
    public String toString() {
        return "Card{" +
                "type=" + type.name() +
                ", name='" + name + '\'' +
                '}';
    }

    public Card(Style type, String name) {
        this.type = type;
        this.name = name;
        this.caculateWeight();
    }

    private void caculateWeight(){

        switch (this.name){
            case "3":
                this.weight = 3;
                break;
            case "4":
                this.weight = 4;
                break;
            case "5":
                this.weight = 5;
                break;
            case "6":
                this.weight = 6;
                break;
            case "7":
                this.weight = 7;
                break;
            case "8":
                this.weight = 8;
                break;
            case "9":
                this.weight = 9;
                break;
            case "10":
                this.weight = 10;
                break;
            case "J":
                this.weight = 11;
                break;
            case "Q":
                this.weight = 12;
                break;
            case "K":
                this.weight = 13;
                break;
            case "A":
                this.weight = 14;
                break;
            case "2":
                this.weight = 15;
                break;
            case "小王":
                this.weight = 16;
                break;
            case "大王":
                this.weight = 17;
                break;
        }
    }

    @Override
    public int compareTo(Card o) {
        return -this.getWeight().compareTo(o.getWeight());
    }
}
